package com.my.zidingyikongjian.view.one;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.view.View;

/**
 * 项目名称：ZiDingYiKongJian
 * 创建人：
 * 创建时间：2018/7/9 17:14
 */

public class OvalView extends View {
    public OvalView(Context context) {
        super(context);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        Paint paint = new Paint();
        paint.setStrokeWidth(5);// 画笔宽度
        paint.setStyle(Paint.Style.STROKE); // 画笔样式 描边式
        paint.setColor(Color.RED);

        RectF rectF = new RectF(100, 10, 300, 100);
        canvas.drawRect(rectF, paint);

        paint.setColor(Color.GREEN); // 更改画笔颜色
        canvas.drawOval(rectF, paint); // 画椭圆
    }
}
